import { get } from './helpers'

const getSeller = get('sell/api/seller.json')
const getGoods = get('sell/buyer/product/list')
const getRatings = get('sell/api/ratings.json')
const getOrderList = get('sell/buyer/order/list')
const getOrderDetail = get('sell/buyer/order/detail')
const getAddress = get('sell/buyer/address/list')
const getDefaultAddr = get('sell/buyer/address/default')
const delAddress = get('sell/buyer/address/del')
const setDefaultAddr = get('sell/buyer/address/set')

function getCookie(name) {
  var arr
  var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
  arr = document.cookie.match(reg)
  if (arr !== null) {
    return unescape(arr[2])
  } else {
    return null
  }
}

function isEmpty(obj) {
  if (typeof obj === 'undefined' || obj === null || obj === '') {
    return true
  } else {
    return false
  }
}

export {
  getSeller,
  getGoods,
  getRatings,
  getOrderList,
  getOrderDetail,
  getAddress,
  getDefaultAddr,
  getCookie,
  delAddress,
  setDefaultAddr,
  isEmpty
}
